#include "../include/vector_operations.h"
#include <numeric>
#include <stdexcept>

int sum(const std::vector<int> &numbers)
{
    return std::accumulate(numbers.begin(), numbers.end(), 0);
}

double average(const std::vector<int> &numbers)
{
    if (numbers.empty())
    {
        throw std::invalid_argument("Cannot compute average of an empty vector");
    }
    return static_cast<double>(sum(numbers)) / numbers.size();
}
